package MULE.Model.Logic;

import java.util.Random;

import MULE.Model.Inventory;
import MULE.Model.Player;
import MULE.Model.Resource;
import MULE.Model.ResourceTile;

/**
 * Responsible for the logic used in the LandOffice.
 * 
 * @author Aaron 11.12.2013
 * 
 */
public class LandOfficeLogic {

	private static final int BASE_SELL_PRICE = 300;
	private static final int SELL_PRICE_VARIABILITY = 100;
	private static Random rand = new Random();

	/**
	 * Sell land. 
	 * 
	 * @param p
	 * @param land
	 * @param price
	 */
	public static void sellLand(Player p, ResourceTile land, Inventory price) {
		// Remove player's ownership and mules.
		land.setOwner(null);
		land.muleOn(false);
		// Add resources to player inventory.
		p.getInventory().add(price);
	}

	/**
	 * Calculate land selling price.
	 * 
	 * @param currentRound
	 * @return
	 */
	public static Inventory calcSellingPrice(int currentRound) {
		Inventory cost = new Inventory();
		int money = BASE_SELL_PRICE;
		money += currentRound * rand.nextInt(SELL_PRICE_VARIABILITY);
		cost.add(Resource.MONEY, money);
		return cost;
	}

}
